﻿namespace Lyricsgrabber.Core.FLAC
{
  internal class VorbisComment : IMetadata
  {
    #region Public / Attributes

    public MetadataType Type { get; private set; }
    public string Value { get; private set; }

    #endregion

    #region Public / Constructors

    public VorbisComment(string comment)
    {
      string[] split = comment.Split('=');

      Type = GetMetadataFromString(split[0]);

      Value = split[1];
    }

    private MetadataType GetMetadataFromString(string type)
    {
      switch (type.ToLower())
      {
        case "artist":
          return MetadataType.Artist;
        case "album":
          return MetadataType.Album;
        case "title":
          return MetadataType.Title;
        case "track":
          return MetadataType.Track;
        case "lyrics":
          return MetadataType.SyncedLyrics;
        case "unsynced lyrics":
          return MetadataType.UnsyncedLyrics;
        default:
          return MetadataType.Unknown;
      }
    }

    #endregion

    public override string ToString()
    {
      return string.Format("{0}: {1}", Type, Value);
    }
  }
}